package cn.com.demo.microservice.consumer.controller;

import cn.com.demo.microservice.consumer.service.ISecurityService;
import cn.com.demo.microservice.reps.ResponseObject;
import cn.com.demo.microservice.reps.Token;
import cn.com.demo.microservice.vo.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
//@RequestMapping("/security")
public class SecurityController {
    @Autowired
    private ISecurityService securityService;
    @PostMapping("/user/login")
    public ResponseObject login(@RequestBody Account account){
        ResponseObject result = new ResponseObject();
        try {
            String token = this.securityService.verifyAccount(account);
            Token tk = new Token();
            tk.setToken(token);
            result.setData(token);
        }catch(Exception e){
            result.setCode(50018);
            result.setMessage("用户名和密码不匹配");
        }
        return result;
    }
}
